﻿/**
* ...
* @author alijayameilio
*/

package particling;

import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Bitmap;
import flash.display.BitmapData;

class ShapeConfig
{
	public var shape(default, null):ShapeType;
	
	public function new(__shape:ShapeType)
	{
		shape = __shape;
	}
	
	public function createParticle():Sprite
	{
		var sprite:Sprite = new Sprite();
		switch(shape) {
			case CIRCLE(radius, color, alpha):
			var shape:Shape = new Shape();
			shape.graphics.beginFill(color, alpha);
			shape.graphics.drawCircle(0, 0, radius);
			sprite.addChild(shape);
			
			case RECTANGLE(width, height, color, alpha):
			var shape:Shape = new Shape();
			shape.graphics.beginFill(color, alpha);
			shape.graphics.drawRect( -1 * width / 2, -1 * height / 2, width, height);
			sprite.addChild(shape);
			
			case BITMAP(bitmapData):
			var bitmap:Bitmap = new Bitmap(bitmapData);
			bitmap.x = -1 * bitmap.width / 2;
			bitmap.y = -1 * bitmap.height / 2;
			sprite.addChild(bitmap);
		}
		
		return sprite;
	}
	
}

enum ShapeType
{
	CIRCLE(radius:Int, color:UInt, alpha:Int);
	RECTANGLE(width:Int, height:Int, color:UInt, alpha:Int);
	BITMAP(bitmapData:BitmapData);
}